#ifndef STRING_H
#define STRING_H

struct String
{
	size_t len;
	char *val;
	HASH_HANDLE;
};

extern String *String_new_n(const char *, size_t);
extern Object *OString_new_n(const char *, size_t);
extern Object *String_eval(Object *);
extern const char *String_to_cstr(Object *);
extern Object *String_equal(Object *, Object *);
extern int string_equal(Object *, Object *);

/* Advised for constant strings only */
#define String_new(s) String_new_n((s), strlen((s)))
#define OString_new(s) OString_new_n((s), strlen((s)))

#define getstrlen(o) (getstring(o)->len)
#define getstrval(o) (getstring(o)->val)
#define setstrlen(o, n) (getstringlen(o) = (n))
#define setstrval(o, v) (getstringval(o) = (v))

#endif /* !STRING_H */
